package com.info.zhiduoduo.pay.controller;

import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.validator.IntIn;
import com.info.zhiduoduo.pay.formbean.zhaoshangbankpay.*;
import com.info.zhiduoduo.pay.service.ZhaoShangBankPayService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("/zhaoshang")
public class ZhaoShangBankPayController {

	@Resource
	ZhaoShangBankPayService zhaoShangBankPayService;

	@ApiOperation("招商银行代付")
	@PostMapping("/agentPay")
	public SmartResult agentPay(@Valid @RequestBody ZhaoShangAgentPayFormBean formBean) {
		return zhaoShangBankPayService.agentPay(formBean);
	}

	@ApiOperation("查询交易概要信息")
	@PostMapping("/queryTransactionOutline")
	public SmartResult queryTransactionOutline(@Valid @RequestBody QueryPayResultFormBean formBean) {
		return zhaoShangBankPayService.queryTransactionOutline(formBean);
	}

	@ApiOperation("招商银行代付结果查询")
	@PostMapping("/queryAgentPay")
	public SmartResult queryAgentPay(@Valid @RequestBody QueryPayResultFormBean formBean) {
		return zhaoShangBankPayService.queryAgentPay(formBean);
	}

	@ApiOperation("招商银行代付明细查询")
	@PostMapping("/queryAgentPayDetailed")
	public SmartResult queryAgentPayDetailed(@Valid @RequestBody QueryPayResultFormBean formBean) {
		return zhaoShangBankPayService.queryAgentPayDetailed(formBean);
	}

	@ApiOperation("招商银行退票明细查询")
	@PostMapping("/queryAgentPayRetreat")
	public SmartResult queryAgentPayRetreat(@Valid @RequestBody QueryPayResultFormBean formBean) {
		return zhaoShangBankPayService.queryAgentPayRetreat(formBean);
	}

	@ApiOperation("招商银行账户详细信息查询")
	@GetMapping("/queryAccountInfo")
	public SmartResult queryAccountInfo(@IntIn(value = {7, 9, 10}, message = "商户号不正确") @RequestParam int merchantId) {
		return zhaoShangBankPayService.queryAccountInfo(merchantId);
	}

	@ApiOperation("查询招商银行交易代码")
	@PostMapping("/queryTransactionCode")
	public SmartResult queryTransactionCode(@Valid @RequestBody QueryTransactionCodeFormBean formBean) {
		return zhaoShangBankPayService.queryTransactionCode(formBean);
	}

	@ApiOperation("查询招商银行账户交易信息查询")
	@PostMapping("/queryTransactionInfo")
	public SmartResult<String> queryTransactionInfo(@Valid @RequestBody QueryTransactionInfoFormBean formBean) {
		return zhaoShangBankPayService.queryTransactionInfo(formBean);
	}

	@ApiOperation("查询招商银行单笔回单")
	@PostMapping("/queryElectronReceiptFile")
	public SmartResult queryElectronReceiptFile(@Valid @RequestBody QueryElectronicReceiptFormBean formBean) {
		return zhaoShangBankPayService.queryElectronReceiptFile(formBean);
	}
	@ApiOperation("查询账户交易信息并生成电子回单")
	@PostMapping("/queryReqnbrCreatElectronReceiptFile")
	public SmartResult queryReqnbrCreatElectronReceiptFile(@Valid @RequestBody QueryTransactionInfoFormBean formBean) {
		return zhaoShangBankPayService.queryReqnbrCreatElectronReceiptFile(formBean);
	}

	@ApiOperation("招行代发明细对账单查询DCAGPPDF（返回打印taskId）")
	@PostMapping("/queryReceiptFile")
	public SmartResult queryReceiptFile(@Valid @RequestBody QueryReceiptFormBean formBean) {
		return zhaoShangBankPayService.queryReceiptFile(formBean);
	}

	@ApiOperation("招行代发明细对账单处理结果查询请求DCTASKID（传taskId,返回打印的链接地址）")
	@PostMapping("/printReceiptFile")
	public SmartResult printReceiptFile(@RequestBody QueryReceiptFormBean formBean) {
		return zhaoShangBankPayService.printReceiptFile(formBean);
	}
}
